---
page_title: "cloudflare_load_balancer_monitor Resource - Cloudflare"
subcategory: ""
description: |-
  If Cloudflare's Load Balancing to load-balance across multiple
  origin servers or data centers, you configure one of these Monitors
  to actively check the availability of those servers over HTTP(S) or
  TCP.
---

# cloudflare_load_balancer_monitor (Resource)

If Cloudflare's Load Balancing to load-balance across multiple
origin servers or data centers, you configure one of these Monitors
to actively check the availability of those servers over HTTP(S) or
TCP.

## Example Usage

```terraform
# HTTP
resource "cloudflare_load_balancer_monitor" "example" {
  account_id     = "f037e56e89293a057740de681ac9abbe"
  type           = "http"
  expected_body  = "alive"
  expected_codes = "2xx"
  method         = "GET"
  timeout        = 7
  path           = "/health"
  interval       = 60
  retries        = 5
  description    = "example http load balancer"
  header {
    header = "Host"
    values = ["example.com"]
  }
  allow_insecure   = false
  follow_redirects = true
  probe_zone       = "example.com"
}

# TCP Monitor
resource "cloudflare_load_balancer_monitor" "example" {
  account_id  = "f037e56e89293a057740de681ac9abbe"
  type        = "tcp"
  method      = "connection_established"
  timeout     = 7
  port        = 8080
  interval    = 60
  retries     = 5
  description = "example tcp load balancer"
}
```
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `account_id` (String) The account identifier to target for the resource.

### Optional

- `allow_insecure` (Boolean) Do not validate the certificate when monitor use HTTPS.  Only valid if `type` is "http" or "https".
- `consecutive_down` (Number) To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. Defaults to `0`.
- `consecutive_up` (Number) To be marked healthy the monitored origin must pass this healthcheck N consecutive times. Defaults to `0`.
- `description` (String) Free text description.
- `expected_body` (String) A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. Only valid if `type` is "http" or "https".
- `expected_codes` (String) The expected HTTP response code or code range of the health check. Eg `2xx`. Only valid and required if `type` is "http" or "https".
- `follow_redirects` (Boolean) Follow redirects if returned by the origin. Only valid if `type` is "http" or "https".
- `header` (Block Set) The HTTP request headers to send in the health check. It is recommended you set a Host header by default. The User-Agent header cannot be overridden. (see [below for nested schema](#nestedblock--header))
- `interval` (Number) The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. Defaults to `60`.
- `method` (String) The method to use for the health check.
- `path` (String) The endpoint path to health check against.
- `port` (Number) The port number to use for the healthcheck, required when creating a TCP monitor.
- `probe_zone` (String) Assign this monitor to emulate the specified zone while probing. Only valid if `type` is "http" or "https".
- `retries` (Number) The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. Defaults to `2`.
- `timeout` (Number) The timeout (in seconds) before marking the health check as failed. Defaults to `5`.
- `type` (String) The protocol to use for the healthcheck. Available values: `http`, `https`, `tcp`, `udp_icmp`, `icmp_ping`, `smtp`. Defaults to `http`.

### Read-Only

- `created_on` (String) The RFC3339 timestamp of when the load balancer monitor was created.
- `id` (String) The ID of this resource.
- `modified_on` (String) The RFC3339 timestamp of when the load balancer monitor was last modified.

<a id="nestedblock--header"></a>
### Nested Schema for `header`

Required:

- `header` (String) The header name.
- `values` (Set of String) A list of values for the header.

## Import

Import is supported using the following syntax:

```shell
$ terraform import cloudflare_load_balancer_monitor.example <account_id>/<load_balancer_monitor_id>
```
